package com.cn.dream_order_server.controller;

import com.cn.dream_order_server.pojo.OrderOrder;
import com.cn.dream_order_server.service.PublicWsfOrderOrderService;
import com.cn.dream_order_server.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;


@RestController
public class PublicWsfOrderOrderController {

    @Autowired
    private PublicWsfOrderOrderService publicWsfOrderOrderService;


    //使用@ResponseBody会将数据转换成json字符串在发送
    @PostMapping("/getOrderByDay")
    public Object getOrderByDay(String dateString){
        System.out.println("222222222222");
        Date date = DateUtils.dateParse(dateString, null);
        List<OrderOrder> orderByDay = publicWsfOrderOrderService.getOrderByDay(date);
        return orderByDay;
    }

    //使用JsonUtils将返回值转换成字符串在发送出去
    @PostMapping("/getOrderByTime")
    public Object getOrderByTime(String beforeSting,String afterString){
        System.out.println("3333333333333");
        Date before = DateUtils.dateParse(beforeSting, null);
        Date after = DateUtils.dateParse(afterString, null);
        List<OrderOrder> allOrderByTime = publicWsfOrderOrderService.getAllOrderByTime(before, after);

        return allOrderByTime;
    }
}
